<?php

/**
 * MemberPhoneNumber form base class.
 *
 * @method MemberPhoneNumber getObject() Returns the current form's model object
 *
 * @package    Wildlive
 * @subpackage form
 * @author     Maximilian Lenkeit <dev@lenki.com>
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseMemberPhoneNumberForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'ID'              => new sfWidgetFormInputHidden(),
      'member_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('PersonalMemberData'), 'add_empty' => false)),
      'phone_number_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('PhoneNumber'), 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'ID'              => new sfValidatorChoice(array('choices' => array($this->getObject()->get('ID')), 'empty_value' => $this->getObject()->get('ID'), 'required' => false)),
      'member_id'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('PersonalMemberData'))),
      'phone_number_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('PhoneNumber'))),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'MemberPhoneNumber', 'column' => array('ID')))
    );

    $this->widgetSchema->setNameFormat('member_phone_number[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'MemberPhoneNumber';
  }

}
